package com.bcn.login_mybatisplus_demo.schedule.controller;

import java.util.List;

import com.bcn.login_mybatisplus_demo.common.controller.BaseController;
import com.bcn.login_mybatisplus_demo.common.page.TableDataInfo;
import com.bcn.login_mybatisplus_demo.pojo.vo.R;
import com.bcn.login_mybatisplus_demo.schedule.domain.TAppSchedule;
import com.bcn.login_mybatisplus_demo.schedule.service.ITAppScheduleService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.ui.ModelMap;
import org.springframework.web.bind.annotation.*;


/**
 * 【请填写功能名称】Controller
 * 
 * @author administrator
 * @date 2025-03-18
 */
@RestController
@RequestMapping("/system/schedule")
public class TAppScheduleController extends BaseController
{
    private String prefix = "system/schedule";

    @Autowired
    private ITAppScheduleService tAppScheduleService;

    @GetMapping()
    public String schedule()
    {
        return prefix + "/schedule";
    }

    /**
     * 查询【请填写功能名称】列表
     */
    @GetMapping("/list")
    public TableDataInfo list(TAppSchedule tAppSchedule)
    {
        startPage();
        List<TAppSchedule> list = tAppScheduleService.selectTAppScheduleList(tAppSchedule);
        return getDataTable(list);
    }

//    /**
//     * 导出【请填写功能名称】列表
//     */
//    @PostMapping("/export")
//    @ResponseBody
//    public AjaxResult export(TAppSchedule tAppSchedule)
//    {
//        List<TAppSchedule> list = tAppScheduleService.selectTAppScheduleList(tAppSchedule);
//        ExcelUtil<TAppSchedule> util = new ExcelUtil<TAppSchedule>(TAppSchedule.class);
//        return util.exportExcel(list, "schedule");
//    }

    /**
     * 新增【请填写功能名称】
     */
    @GetMapping("/add")
    public String add()
    {
        return prefix + "/add";
    }

    /**
     * 新增保存【请填写功能名称】
     */
    @PostMapping("/add")
    public R addSave(@RequestBody TAppSchedule tAppSchedule)
    {
        return R.success(tAppScheduleService.insertTAppSchedule(tAppSchedule));
    }

    /**
     * 修改【请填写功能名称】
     */
    @GetMapping("/edit/{id}")
    public String edit(@PathVariable("id") Long id, ModelMap mmap)
    {
        TAppSchedule tAppSchedule = tAppScheduleService.selectTAppScheduleById(id);
        mmap.put("tAppSchedule", tAppSchedule);
        return prefix + "/edit";
    }

    /**
     * 修改保存【请填写功能名称】
     */
    @PostMapping("/edit")
    public R editSave(@RequestBody TAppSchedule tAppSchedule)
    {
        return R.success(tAppScheduleService.updateTAppSchedule(tAppSchedule));
    }

    /**
     * 删除【请填写功能名称】
     */
    @GetMapping( "/remove/{id}")
    public R remove(@PathVariable("id") String id)
    {
        return  R.success(tAppScheduleService.deleteTAppScheduleByIds(id));
    }
}
